#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	gerchar();
	while (m--)
	{
        int total = 1 << n;
	    int num = 1 << n;
		char c = 0;
		while ((c = getchar()) != '\n')
		{
			scanf("%c", &c);
			num = num / 2;
			if (c == 'y')
			{
				total = total - num;
			}
		}
		printf("%d\n", total);
	}
	return 0;
}